import time
from threading import Thread

tags = {"test": "t_value"}


def async_fun(f):
    def wrapper(*args, **kwargs):
        thr = Thread(target=f, args=args, kwargs=kwargs)
        thr.start()

    return wrapper


@async_fun
def last(tag, second, function, args=()):
    tag_time = time.time()
    tags[tag] = tag_time
    time.sleep(second)

    # 时间没有被更改，则可以执行function
    if tags[tag] == tag_time:
        function(*args)
